package com.yunkeji.api.pay.controller;

import com.yunkeji.api.pay.bo.PiggyToSign;
import com.yunkeji.api.pay.service.PayService;
import com.yunkeji.common.annotation.RepeatSubmit;
import com.yunkeji.common.core.controller.BaseController;
import com.yunkeji.common.core.domain.R;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.concurrent.TimeUnit;

/** 电签 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/v1/piggy")
public class PiggyController extends BaseController {
    private final PayService payService;
    /**
     * 前去电签
     *
     * @author 老张
     * @return
     */
    @PostMapping(value = "/piggyToSign")
    @ResponseBody
    @RepeatSubmit(interval = 1, timeUnit = TimeUnit.MINUTES, message = "操作过快,请一分钟后再试")
    public R piggyToSign(@Valid @RequestBody PiggyToSign piggyToSign) {
        return R.ok("获取电签地址成功", payService.piggyToSign(piggyToSign));
    }
}
